package cz.muni.fi.pb138.bookinfo;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

public class Authors extends Activity {
	private Button bJB;
	private Button bMN;
	private Button bPS;
	private Button bJV;

	/** Called when the activity is first created. 
	 *  Creates listeners to all buttons.
	 *  Shows the authors of this application.
	 */
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.authors);

		bJB = (Button) findViewById(R.id.JB);
		bMN = (Button) findViewById(R.id.MN);
		bPS = (Button) findViewById(R.id.PS);
		bJV = (Button) findViewById(R.id.JV);

		bJB.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				openWebURL("https://is.muni.cz/auth/osoba/374289");
			}
		});

		bMN.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				openWebURL("https://is.muni.cz/auth/osoba/374505");
			}
		});

		bPS.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				openWebURL("https://is.muni.cz/auth/osoba/373947");
			}
		});

		bJV.setOnClickListener(new View.OnClickListener() {
			public void onClick(View v) {
				openWebURL("https://is.muni.cz/auth/osoba/374138");
			}
		});
	}
	
	/**
	 * Opens the web browser with given URL.
	 * 
	 * @param inURL URL to be open in web browser
	 */
	public void openWebURL(String inURL) {
	    Intent browse = new Intent(Intent.ACTION_VIEW, Uri.parse(inURL));

	    startActivity(browse);
	}
}
